mmmm(some typical operations on a metal image Grains.Steel Grains.SteelÒØӨ8@9Òӧä @@@8ØØ tӦjөNӪbmmmmmm$First, load the image "Grains.Steel"other images open)H@ÒØӨ8@9Òӧu @@@8ØV`0@V2 tӦjөNӪbm7these examples will be most effective if you highlight a  H@L@  @@@L HLL d 4each portion of the script and execute it separatelyH@LL,L\X\:@ L\9LL- @@@LL,L!\86\;\<.mmmm-----@ (@"@@@H@L@ > @@@LLL dmmmmmm:Level the background for thresholding the grain boundariesH@L@ > @@@LHLLL dmmmmm#one way is by using a rank operator@@MEH@LL,L\X\6H@ L\5L3: @@@LMEML,L!\4zME\7^\8rmbackgroundo @ /@"o,@@@N@/o@ /o\ @@@L Wk. dm |`pܧ  background @ ]@"@@@@&N@]\q0ْ V@ ] мh @@@LL& S)\q0!Ř| L& l"Jmmmm7select the brightest neighbor pixel to erase boundariesMH@L$xL,L\X\6H@ L$x\5L3: @@@LMMHL,L@p\7^\8rMH\4zM\7^\8rmm&this uses the built-in 3x3 rank filter3OĠH@ÓØӤ|@9Óӣ @@@8ĠěØØ@ tӢĠӥӦ"Dž3(could also use the 5x5 octagonal PCMD for ranking)ěH@<ØӤ|@9<ӣ @@@8ěĜØØ9 tӢěӥӦ"vbackground @ ]@"@@@@&N@]\q0ْ V@ ] мh @@@LL& S)\q0!Ř| L& l"Zbackground @ ]@"@@@@&N@]\q0ْ V@ ] мh @@@LL& S)\q0!Ř| L& l"gbackground @ ]@"@@@@&N@]\q0ْ V@ ] мh @@@LL& S)\q0!Ř| L& l"vbackground @ ]@"@@@@&N@]\q0ْ V@ ] мh @@@LL& S)\q0!Ř| L& l"Džbackground @ ]@"@@@@&N@]\q0ْ V@ ] мh @@@LL& S)\q0!Ř| L& l"ǔ background @ ]@"@@@@&N@]\q0ْ V@ ] мh @@@LL& S)\q0!Ř| L& l"Ǖbackground @ ]@"@@@@&N@]\q0ْ V@ ] мh @@@LL& S)\q0!Ř| L& l"ǖ background @ ]@"@@@@&N@]\q0ْ V@ ] мh @@@LL& S)\q0!Ř| L& l"ǭbackground @ ]@"@@@@&N@]\q0ْ V@ ] мh @@@LL& S)\q0!Ř| L& l"ǯ backgroundelL,L\9 ""L,Lj\=,&\; \;晙XhL-L$\$\\LL-L$@P@\L @LL$L<\X\9L<@ \X#Lt\9*\<\=(@H:x@ "{ @@H Dcn00@ @ {D  9#?D {ƺƺDD@X:9#ƺƐ ƺh3grey-scale erosion is one method to form background H@p̹@9̹Uj @@@8pp t̷̺̻"ǖ m P:HX.auto BG fitting would also work for this imageH@p̹@9̹^ @@@8pp t̷̺̻ mmmmm-----@ @"@@@H@L@ > @@@LLLL dmmmmmm5Threshold the grain boundaries to make a binary imageH@L@ > @@@L@@ i @@ i & @@ f dmmmmm8first, make copies for a "double thresholding" operationH@LØӨ8@9LӧˀZ @@@8ØØ tӦjөNӪbm copy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܧ copy2p@o@9@o@0@@3O`N@ߐp@o~@9og @@@8`` <ߐߐWk to`` ooS>set threshold levels to get parts of the boundaries, not noiseoundaries and n@  @@@LX LL dX copy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܩSar2copy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܩSkcopy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܩSmcopy2L@Ó$Øө@9Ó$ө&ˇ @@@JØ]$@ LӨ@0@@3O@ibÒ×`@9 tӧXө(ØBĩS3select all boundary points plus noise in other copy[H@pØӤ|@9pӣˇ @@@8[ _ØØ tӢ[ ӥӦcopy2 Ò @@̄@0@@3O@ÒØө.@9Ò@n˂ @@@"Øk"ө$ tӧ^"ӪNӫ\Scopy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܩSa+2copy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܩSkcopy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܩSmmmmm6combine images to keep entire boundaries but not noiseeH@L@  @@@L@ @J;B D dmmmmm0(this is one use of the "feature AND" operation) H@L@  @@@L@ @J;B D  D4@ d mcopy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܧmmmmdiscard the extra copy copyӧ@0@@3O+H@ÓØӨ8@9Óӧˀ: @@@8+ØØ tӦj+өNӪbmmcopy2pÒ @@̄@0@@3OÒ@ÒØө.@9Ò@nˉ, @@@,Ø ,ө$ tӧ^,ӪNӫ\!@H:x@ "{ @@H Dcn00@ @ {D  9#?D {ƺƺDD@X:9#ƺƐ ƺhmmmm-----@ @"@@@H@L@  @@@L(LLL dmmmmm6Prepare for various measurements of image and features,H@Lt@  @@@L,LL d,mmmmm#make sure grain size options are ON@@ H@(L@ ( @@@L 6 LLL d 6mmccopy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܧ Bmmmm)skeletonize to reduce boundaries in width H@L@  @@@L 58LL d 5m7also reports the grain size from the triple point count triple point countLt@ . @@@L/LL d/ c@H:x@ "f @@H Dcn00@ @ fD  6?D fƺƺDD@X:6ƺƐ ƺh m=hSkelGSimmmm+color scale shows blue branches on skeleton(H@L@  @@@L(5@ @J;B D(5 d(5mcopy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܧjset paintbrush color to white@@@H@L@ * @@@LG(LLBin dGecopy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܧq'select the blue color with thresholdingH@L@  @@@LFLLL dF Bcopy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܧt copy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܧ copy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܧerase the blue branch lines@@@H@L@  @@@LELL dE ccopy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܧ})make all remaining non-white pixels black8H@L@  @@@L8E@LL d8Eucopy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܧ6thicken lines to separate the grains (4-connectedness)H@L@  @@@LQLL dQcopy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܧ+and invert for grains instead of boundariesriesH@L@  @@@L@ @J;B DP D4@ dPcopy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܧ%global measurement reports grain size based on mean intercept distanceLt@ . @@@LBLL dB! based on mean intercept distance@@HH@L@  @@@LHWʰLL d HWcopy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܧ:H(dGlobalGS@&@@J @̽ H alalal(-----@ `@"@@@θH@L@  @@@LθVXLL dθV/Perform feature-specific measurements on grainsXH@L@  @@@LXULL dXU*set color scale to show results of rankingH@L@  @@@LS@ @J;B DS dScopy0$o @ 0$@"o,@@@N@/lo@ /lo차 @@@L Wk. dm |`pܧ'and turn on some measurement parametersH@@ @J;B D` D4@L@o@n@p0 d` . @@H:x@ "f @@H Dcn00@ @ fD  :?D fƺƺDD@X::ƺƐ ƺh #copy0$o @ 0$@o@0@@3O`N@ߐp@o~@9og @@@8`` <ߐߐWk to`` ooTcopy0$o @ 0$@o@0@@3O`N@ߐp@o~@9og @@@8`` <ߐߐWk to`` ooTNcopy0$o @ 0$@o@0@@3O`N@ߐp@o~@9og @@@8`` <ߐߐWk to`` ooTW @W /size distrib_t@^np_ b!t^np@ ^n^m*"?^npnv@^^np^npn@n*@nBnnf_a_t@^np^npWk b!y^m*"^m*"?_ ^np!^m^@U copy^np_pD_y5z0t^np@ ^n^mC5W_pDnh@^^np_pDnx@n@nNnnx_t@^np_pDnn4y5z0 ^mC5W^mC5W^np_Kn -copy0$o @ 0$@o@0@@3O`N@ߐp@o~@9og @@@8`` <ߐߐWk to`` ooT copy0$o @ 0$@o@0@@3O`N@ߐp@o~@9og @@@8`` <ߐߐWk to`` ooTNcopy0$o @ 0$@o@0@@3O`N@ߐp@o~@9og @@@8`` <ߐߐWk to`` ooTW @W /nbor distrib_r^np_ b%8<t^np@ ^n^m*"?^npnv@^^np^npn@n*@nBnnf_u__r^np^npWk b%8<y^m*"^m*"?_ ^np!^m^@T F^mTf^nTn @ tnf@T^@znT@nTn@nTn @l^nnntnTTfnnZ@Dn^@n@n) nna&n#could perform more ranked measures @@(H@<L@ < @@@L(bL @`@p d(b ,or save feature data in a file for PrismCalcRH@pØӨ8@9pӧa @@@8RØØ tӦjRөNӪb $"N O mKASTM Grain size by triple-point method from skeleton (number per unit area)(̳^@9̲Y @@@8`pp| @J ṯ`̴|̶~H"d\~vH ?ASTM Grain size by Sv method (length of boundary per unit area)@Pp̳^@9P̲Y @@@80^pp| @J ṯ0^̴|̶~:HmmmmTHE ENDmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm